#pragma once
#include<pthread.h>
#include<iostream>

namespace CondModule
{
    class  Cond
    {
    public:

    void Signal()
    {
        //发送单个信号
        pthread_cond_signal(&_cond);
    }
    void Broadcast()
    {
        //广播
        pthread_cond_broadcast(&_cond);
    }
    Cond()
    {
        pthread_cond_init(&_cond,nullptr);
    }
    ~Cond()
    {
        pthread_cond_destroy(&_cond);
    }
    void Wait(pthread_mutex_t *p)
    {
        pthread_cond_wait(&_cond,p);
    }
    private:
    pthread_cond_t _cond;    
    };
}